import { createStore } from 'vuex'
import { lockFun } from '../utils'
export default createStore({
  state: {
    editMode: 'edit',//编辑模式 用来控制全局锁屏
    curComponent: null, //当前选中的component
    columnList:[],//当前分区的数据
    defaultSettingList: [],  //当前分区的内部分析实例的数据
    customdivList:[] //外框数据
  },
  mutations: {
    //当前操作的数据
    setCurComponent(state, { component }) {
      state.curComponent = component
      // console.log(state.curComponent, "==curComponent")
    },
    //修改画布样式
    setEditorStyle({ curComponent }, { top, left, width, height, rotate }) {
      // console.log(curComponent,"===setEditorStyle")
      if (top) curComponent.customStyle.top = top
      if (left) curComponent.customStyle.left = left
      if (width) curComponent.customStyle.width = width
      if (height) curComponent.customStyle.height = height
      if (rotate) curComponent.customStyle.rotate = rotate
    },
    // shape组件滑动时,改变大小时 更新位置
    //eslint-disable-next-line
    setShapeStyle({ curComponent }, { top, left, width, height, rotate }) {
      // console.log(curComponent,"curComponent")
      if (top || top === 0) curComponent.fxffY = top
      if (left || left === 0) curComponent.fxffX = left
      if (width) curComponent.fxffWidth = width
      if (height) curComponent.fxffHeight = height
      // if (rotate) curComponent.rotate = rotate
      // console.log(sizeW, 'sizeW')
      // console.log(sizeH, 'sizeH')
      // if (sizeW) curComponent.sizeW = sizeW
      // if (sizeH) curComponent.sizeH = sizeH
    },
    setDisableStyle({ curComponent }, { background, flag }) {
      lockFun(curComponent, background, flag)
      console.log(curComponent, flag, "===qqqcurComponent")
      // curComponent.isDisable = true
      // curComponent.customStyle.background = background
    },
    //eslint-disable-next-line
    setExampleInEchartsStyle({ curComponent, canvasStyleData }) {

      // curComponent.childrenData.map(item => {
      //     const width = floatRound(curComponent.customStyle.width * item.sizeW - 2)
      //     const height = floatRound(curComponent.customStyle.height * item.sizeH - canvasStyleData.headerHeight)
      //     item.customStyle.width = width
      //     item.customStyle.height = height
      // })
    },
    //eslint-disable-next-line
    setAllShapeStyle({ curComponent, canvasStyleData }) {
      // curComponent.childrenData.map(item => {
      //     const width = floatRound(curComponent.customStyle.width * item.sizeW - 2)
      //     const height = floatRound(curComponent.customStyle.height * item.sizeH - canvasStyleData.headerHeight)
      //     item.customStyle.width = width
      //     item.customStyle.height = height
      //     item.childrenData.map(ii => {
      //         const ww = floatRound(width * ii.sizeW - 2)
      //         const hh = floatRound(height * ii.sizeH - canvasStyleData.headerHeight)
      //         ii.customStyle.width = ww
      //         ii.customStyle.height = hh
      //     })

      // })
    },
    //获取默认的分析实例的设置
    setDefaultSettingList(state,data){
      state.defaultSettingList = data
    },
    //获取tab页的数据
    setColumnList(state,data){
      state.columnList = data
    },
    //获取外框数据
    setCustomDivList(state,data){
      state.customdivList = data
    },
    //修改外框的width
    setCustomDivWidth(state,{newWidth}){
      state.customdivList[0].width = newWidth
    }
  },
  actions: {
  },
  modules: {
  }
})
